use strict;

open FV,"down.bat";

my $cmd;
my @cmds = ();
while ($cmd=<FV>) {
	chomp($cmd);
	push @cmds, $cmd;
}

my $PID_NUM = 60;
my $this_pid;
foreach my $process (0 .. $PID_NUM) {
	my $pid = fork();
	if ($pid == 0) {
		my $idx = 0;
		$this_pid = $process;
		while ($idx * $PID_NUM + $this_pid < scalar(@cmds)) {
			my $down_cmd = $cmds[$idx * $PID_NUM + $this_pid];
			#print "$this_pid: $down_cmd\n";
			system($down_cmd);
			$idx++;
		}
		last;
	} else {
		next;
	}
}

print "$this_pid The end\n";
if (defined($this_pid)) {exit(0);}
foreach my $wait_id (0 .. $PID_NUM) {
	wait();
}

print "main exit\n";


